﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ВУИ
{
    public partial class Dinam : Form
    {
        public int id;
        public Form1 Main;
        public Dinam(int ID, Form1 MAIN)
        {
            id = ID;
            Main = MAIN;
            InitializeComponent();
            if (Main.lPatient[Main.itnPatietn(id)].Fiz == null) Main.lPatient[Main.itnPatietn(id)].Fiz = new List<Fizcs>();
            dataGridView1.DataSource = Main.lPatient[Main.itnPatietn(id)].Fiz;
            if (Main.lPatient[Main.itnPatietn(id)].Rez == null) Main.lPatient[Main.itnPatietn(id)].Rez = new List<Rez>();
            dataGridView2.DataSource = Main.lPatient[Main.itnPatietn(id)].Rez;
            if (Main.lPatient[Main.itnPatietn(id)].Gr == null) Main.lPatient[Main.itnPatietn(id)].Gr = new List<Group>();
            dataGridView3.DataSource = Main.lPatient[Main.itnPatietn(id)].Gr;
            
        }

        private void Dinam_Load(object sender, EventArgs e)
        {

        }

        private void новыйToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Fizcs e1 = new Fizcs();
            Main.lPatient[Main.itnPatietn(id)].Fiz.Add(e1);
            dataGridView1.DataSource = Main.lPatient[Main.itnPatietn(id)].Fiz;
            Close();
        }

        private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
                Main.lPatient[Main.itnPatietn(id)].Fiz.RemoveAt(dataGridView1.Rows.IndexOf(dataGridView1.SelectedRows[0]));
            Close();
        }

        private void новыйToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Rez e1 = new Rez();
            Main.lPatient[Main.itnPatietn(id)].Rez.Add(e1);
            dataGridView2.DataSource = Main.lPatient[Main.itnPatietn(id)].Rez;
            Close();
        }

        private void удалитьToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (dataGridView2.SelectedRows.Count == 1)
                Main.lPatient[Main.itnPatietn(id)].Rez.RemoveAt(dataGridView2.Rows.IndexOf(dataGridView2.SelectedRows[0]));
            Close();
        }

        private void новыйToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            Group e1 = new Group();
            Main.lPatient[Main.itnPatietn(id)].Gr.Add(e1);
            dataGridView3.DataSource = Main.lPatient[Main.itnPatietn(id)].Gr;
            Close();
        }

        private void удалитьToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            if (dataGridView3.SelectedRows.Count == 1)
                Main.lPatient[Main.itnPatietn(id)].Gr.RemoveAt(dataGridView3.Rows.IndexOf(dataGridView3.SelectedRows[0]));
            Close();
        }

        private void dataGridView3_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            Fgroupcs f = new Fgroupcs(Main, id, e.RowIndex);
            f.ShowDialog();
            Close();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SDNReport s = new SDNReport(Main,id);
            s.ShowDialog();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
